test:
	echo test
#build:
#	docker build -t "ucx/puppetbase" .

docker-base:
	docker-compose run base
#	docker run -ti --privileged -e "container=docker" -p 80:80 -p 443:443 -p 8003:8003 -p 8180:8180 -v `pwd`:/vagrant -v `pwd`/../../a2_ucx/webapp:/vagrant/webapp ucx/puppetbase /usr/sbin/init

docker:
	docker-compose run -d --service-ports a2ucx-hf

docker-fz:
	docker-compose run -d --service-ports a2ucx-fz
#	docker run -ti --privileged -e "container=docker" -p 80:80 -p 443:443 -p 8003:8003 -p 8180:8180 -v `pwd`:/vagrant -v `pwd`/../../a2_ucx/webapp:/vagrant/webapp ucx/puppetdone /usr/sbin/init

provision:
	docker-compose run -d --service-ports a2ucx-provision
	docker exec -ti `docker ps -f "name=a2ucx-provision" -q` bash

provision-fz:
	docker-compose run -d --service-ports a2ucx-provision
	docker exec -ti `docker ps -f "name=a2ucx-provision" -q` bash
#   下面的命令手动执行
#	cd /vagrant && make puppet-apply
#   or
#   cd /vagrant/vagrant && make deploy_pcx
#   cd /vagrant/webapp && ./yii migrate
#   rm -rf /tmp/vagrant-cache/* && yum clean all
#   exit
#   docker commit `docker ps -f "name=a2ucx-provision" -q` repo.connectedpdf.com:5000/ucx/puppetdone:`date +%Y%m%d`
#   docker tag repo.connectedpdf.com:5000/ucx/puppetdone:`date +%Y%m%d` repo.connectedpdf.com:5000/ucx/puppetdone
#   docker push repo.connectedpdf.com:5000/ucx/puppetdone:`date +%Y%m%d`
#   docker push repo.connectedpdf.com:5000/ucx/puppetdone

clean:
	docker rm `docker ps -q > /tmp/docker.txt && docker ps -q -a >> /tmp/docker.txt && cat /tmp/docker.txt | sort | uniq -u && rm /tmp/docker.txt`

prepare-puppet:
	yum -y update
	yum -y install ruby ruby-libs ruby-shadow
	rpm -Uvh http://yum.puppetlabs.com/el/7Server/products/x86_64/puppetlabs-release-7-12.noarch.rpm
	yum -y install puppet-server
	yum -y install git
	yum clean all

puppet-apply:
	puppet apply -v --debug --modulepath=/vagrant/puppet/modules ./puppet/manifests/a2ucx.pp
	cd /vagrant/vagrant && ./provision.sh
	cd /vagrant/vagrant ./non_windows_shell.sh
	cd /vagrant/vagrant && ./post_provision.sh
	rm -rf /tmp/vagrant-cache/* && yum clean all

vendor:
	\cp -f puppet/modules/smx_os/files/functions.sh vagrant/functions.sh
	\cp -f puppet/modules/smx_tools/files/Makefile vagrant/Makefile
	\cp -f puppet/modules/smx_tools/files/p1_utils.sh vagrant/p1_utils.sh
	\cp -f puppet/modules/smx_download/files/download_files.sh vagrant/download_files.sh
	\cp -f puppet/modules/smx_os/files/prepare_composer.sh vagrant/prepare_composer.sh
	cd vagrant && ./p1_utils.sh -clear_download_cache &&./prepare_composer.sh

ssh:
	sh docker_ssh.sh

test2:
	echo test2